package com.building.hcrm.common;

import java.util.List;

import com.building.hcrm.base.BaseParam;
import com.building.hcrm.model.SysUser;
import com.building.hcrm.wcf.UserServiceProxy;

import android.content.Context;
import android.util.Log;

public class InStaffList 
{
	private final String  LTAG= InStaffList.class.getSimpleName();

	private static InStaffList _instance;

	private Context _context;

	public static InStaffList getInstance(Context context)
	{
		if (_instance == null)
		{
			_instance = new InStaffList();
		}
		_instance._context = context;
		return _instance;
	}

	private List<SysUser> _list;

	/**
	 * 初始化团队成员(含自己)
	 * @return
	 */
	public List<SysUser> initList()
	{
		try
		{
			if (_list == null || _list.size() == 0)
			{
				BaseParam param = new BaseParam();
				param.userNum = User.getInstance(_context).getUserNum();
				_list = UserServiceProxy.getInstance(_context).UserOfBranchAndSelf(param);
			}
		}
		catch (Exception e)
		{
			Log.e(LTAG, ComFunc.getExceptionMessage(e),e);
		}
		return _list;
	}

	/**
	 * 获取团队成员(含自己)——需先初始化
	 * @return
	 */
	public List<SysUser> getList()
	{
		return _list;
	}
	
	private List<SysUser> _subList;

	/**
	 * 初始化下属成员（不含自己）
	 * @return
	 */
	public List<SysUser> initSubList()
	{
		try
		{
			if (_subList == null)
			{
				BaseParam param = new BaseParam();
				param.userNum = User.getInstance(_context).getUserNum();
				_subList = UserServiceProxy.getInstance(_context).UserOfBranch(param);
			}
		}
		catch (Exception e)
		{
			Log.e(LTAG, ComFunc.getExceptionMessage(e),e);
		}
		return _subList;
	}

	/**
	 * 获取下属成员（不含自己）——需先初始化
	 * @return
	 */
	public List<SysUser> getSubList()
	{
		return _subList;
	}
}
